home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wtek0693.zip / ECKEL.ZIP / MULTIMED.H < prev   
C/C++ Source or Header  |  1992-07-15  |  2KB  |  62 lines

  1. //: MULTIMED.H -- MultiMedia Classes
  2. #ifndef MULTIMED_H_
  3. #define MULTIMED_H_
  4. const sz = 100;
  5.  
  6. // Note this uses the MCI string interface, but
  7. // the implementation is hidden so you could use
  8. // a different implementation without affecting
  9. // the rest of the code.
  10. class CD {
  11.   int present; // is there a CD player present?
  12.   int maxtracks;  // maximum number of tracks on CD
  13.   struct songlength { int minutes, seconds; }
  14.      *length; // array of track lengths
  15.   int track, minute, second;  // current CD values
  16.   char command[sz];  // for mci command string
  17.   int cd_open;  // indicates whether CD is open
  18.   int open();  // insures CD is open
  19.   void update_position(); // update track, minute, second
  20.   enum { normal, fforward, frewind } state;
  21. public:
  22.   enum when { open_now, open_later };
  23.   CD(when w = open_later);
  24.   ~CD();
  25.   void play(); // plays from current position
  26.   void stop(); // stop, return to beginning
  27.   void forward_track(); // won't go past end
  28.   void backward_track(); // won't go past beginning
  29.   void rewind();
  30.   void rewind_step();
  31.   void fast_forward();
  32.   void fforward_step();
  33.   void bump() {
  34.     if (state == fforward) fforward_step();
  35.     else if (state == frewind) rewind_step();
  36.     else if (state == normal) update_position();
  37.   }
  38.   int trackNow() { return track; }
  39.   int minuteNow() { return minute; }
  40.   int secondNow() { return second; }
  41. };
  42.  
  43. extern CD cd;  // single global instance
  44.  
  45. class SoundPlayer {
  46. protected:
  47.   char command[sz];  // for mci command string
  48. public:
  49.   void play(char * file);  // play a .WAV file
  50. };
  51.  
  52. class SoundRecorder : public SoundPlayer {
  53.   int audio_used, recording;
  54. public:
  55.   SoundRecorder();
  56.   ~SoundRecorder();
  57.   void start_recording();
  58.   void stop_recording();
  59.   void save(char * file); // save the .WAV file just recorded
  60. };
  61.  
  62. #endif // MULTIMED_H_